package overall.manager
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	import morn.core.components.FrameClip;
	import morn.core.handlers.Handler;

	public class MagicFaceManager extends EventDispatcher
	{
		public function MagicFaceManager()
		{
		}
		static private var _instance:MagicFaceManager;
		static public function get instance():MagicFaceManager{
			_instance=_instance||new MagicFaceManager;
			return _instance;
		}
		
		static public const TRIGGER_CANNON:String="trigger_cannon";
		static public const TRIGGER_PUMP:String="trigger_pump";
		private var _movieSp:FrameClip;
		private var hanld:Handler;
		public function show(style:String,isMove:Boolean=false):void
		{
			hide()
			hanld=new Handler(completeFuc)
		    switch(style){
				case "trigger_cannon":
					_movieSp=new FrameClip("frameclip_trigger_cannon");
					break;
				case "trigger_pump":
					_movieSp=new FrameClip("frameclip_trigger_pump");
					break;
			}
			if(_movieSp){
				LayerManager.instance.magicLayer.addChild(_movieSp);
				if(isMove){
					_movieSp.playFromTo(null,null,hanld);
				}
			}
		}
		private function completeFuc():void{
			hide();
			this.dispatchEvent(new Event(Event.COMPLETE));
		}
		public function hide():void
		{
			if(_movieSp){
				if(_movieSp.parent){
					_movieSp.parent.removeChild(_movieSp);
				}
				_movieSp=null;
			}
		}
		
		
	}
}